home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  7.6 KB  |  304 lines

  1. /*                                                    Utitlity macros for the W3 code library
  2.                                   MACROS FOR GENERAL USE
  3.                                              
  4.    Generates: HTUtils.h
  5.    
  6.    See also: the system dependent file "tcp.h"
  7.    
  8.  */
  9.  
  10. #ifndef DEBUG
  11. #define DEBUG   /* Noone ever turns this off as trace is too important */
  12. #endif          /* Keeep option for really small memory applications tho */
  13.                 
  14. #ifndef HTUTILS_H
  15. #define HTUTILS_H
  16.  
  17. #ifdef _WINDOWS                         /* SCW */
  18. #include "windef.h"
  19. #define BOOLEAN_DEFINED
  20. #endif
  21.  
  22. #ifdef SHORT_NAMES
  23. #define WWW_TraceFlag HTTrFlag
  24. #endif
  25.  
  26. /*
  27.  
  28. Debug message control.
  29.  
  30.  */
  31. #ifndef STDIO_H
  32. #include <stdio.h>
  33. #define STDIO_H
  34. #endif
  35.  
  36. #ifdef DEBUG
  37. #define TRACE (WWW_TraceFlag)
  38. #define PROGRESS(str) printf(str)
  39.         extern int WWW_TraceFlag;
  40. #else
  41. #define TRACE 0
  42. #define PROGRESS(str) /* nothing for now */
  43. #endif
  44.  
  45. #define CTRACE if(TRACE)fprintf
  46. #define tfp stderr
  47.  
  48. /*
  49.  
  50.   ERROR TYPE
  51.   
  52.    This is passed back when streams are aborted. It might be nice to have some structure
  53.    of error messages, numbers, and recursive pointers to reasons. Curently this is a
  54.    placeholder for something more sophisticated.
  55.    
  56.  */
  57. typedef void * HTError;                 /* Unused at present -- best definition? */
  58.  
  59. /*
  60.  
  61. Standard C library for malloc() etc
  62.  
  63.  */
  64. #ifdef vax
  65. #ifdef unix
  66. #define ultrix  /* Assume vax+unix=ultrix */
  67. #endif
  68. #endif
  69.  
  70. #ifndef VMS
  71. #ifndef ultrix
  72. #ifdef NeXT
  73. #include <libc.h>       /* NeXT */
  74. #endif
  75. #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
  76. #ifndef __STRICT_BSD__
  77. #include <stdlib.h>
  78. #endif
  79.  
  80. #endif
  81. #else /* ultrix */
  82. #include <malloc.h>
  83. #include <memory.h>
  84. #include <stdio.h>
  85. #include <stdlib.h>   /* ANSI */   /* BSN */
  86. #endif
  87.  
  88. #else   /* VMS */
  89. #include <stdlib.h>
  90. #include <unixlib.h>
  91. #include <ctype.h>
  92. #if defined(VAXC) && !defined(__DECC)
  93. #define malloc    VAXC$MALLOC_OPT
  94. #define calloc    VAXC$CALLOC_OPT
  95. #define free    VAXC$FREE_OPT
  96. #define cfree    VAXC$CFREE_OPT
  97. #define realloc    VAXC$REALLOC_OPT
  98. #endif /* VAXC && !__DECC */
  99. #endif /* VMS */
  100.  
  101. /*
  102.  
  103. Macros for declarations
  104.  
  105.  */
  106. #define PUBLIC                  /* Accessible outside this module     */
  107. #define PRIVATE static          /* Accessible only within this module */
  108.  
  109. #ifdef __STDC__
  110. #define CONST const             /* "const" only exists in STDC */
  111. #define NOPARAMS (void)
  112. #define PARAMS(parameter_list) parameter_list
  113. #define NOARGS (void)
  114. #define ARGS1(t,a) \
  115.                 (t a)
  116. #define ARGS2(t,a,u,b) \
  117.                 (t a, u b)
  118. #define ARGS3(t,a,u,b,v,c) \
  119.                 (t a, u b, v c)
  120. #define ARGS4(t,a,u,b,v,c,w,d) \
  121.                 (t a, u b, v c, w d)
  122. #define ARGS5(t,a,u,b,v,c,w,d,x,e) \
  123.                 (t a, u b, v c, w d, x e)
  124. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
  125.                 (t a, u b, v c, w d, x e, y f)
  126. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
  127.                 (t a, u b, v c, w d, x e, y f, z g)
  128. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
  129.                 (t a, u b, v c, w d, x e, y f, z g, s h)
  130. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
  131.                 (t a, u b, v c, w d, x e, y f, z g, s h, r i)
  132. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
  133.                 (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
  134.  
  135. #else  /* not ANSI */
  136.  
  137. #ifndef _WINDOWS
  138. #define CONST
  139. #endif
  140. #define NOPARAMS ()
  141. #define PARAMS(parameter_list) ()
  142. #define NOARGS ()
  143. #define ARGS1(t,a) (a) \
  144.                 t a;
  145. #define ARGS2(t,a,u,b) (a,b) \
  146.                 t a; u b;
  147. #define ARGS3(t,a,u,b,v,c) (a,b,c) \
  148.                 t a; u b; v c;
  149. #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
  150.                 t a; u b; v c; w d;
  151. #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
  152.                 t a; u b; v c; w d; x e;
  153. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
  154.                 t a; u b; v c; w d; x e; y f;
  155. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
  156.                 t a; u b; v c; w d; x e; y f; z g;
  157. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
  158.                 t a; u b; v c; w d; x e; y f; z g; s h;
  159. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
  160.                 t a; u b; v c; w d; x e; y f; z g; s h; r i;
  161. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
  162.                 t a; u b; v c; w d; x e; y f; z g; s h; r i; q j;
  163.                 
  164.         
  165. #endif /* __STDC__ (ANSI) */
  166.  
  167. #ifndef NULL
  168. #define NULL ((void *)0)
  169. #endif
  170.  
  171. /*
  172.  
  173. Booleans
  174.  
  175.  */
  176. /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
  177. /* #define GOOD(status) ((status)38;1)   VMS style status: test bit 0         */
  178. /* #define BAD(status)  (!GOOD(status))  Bit 0 set if OK, otherwise clear   */
  179.  
  180. #ifndef _WINDOWS
  181. #ifndef BOOLEAN_DEFINED
  182.         typedef char    BOOLEAN;                /* Logical value */
  183. #ifndef CURSES
  184. #ifndef TRUE
  185. #define TRUE    (BOOLEAN)1
  186. #define FALSE   (BOOLEAN)0
  187. #endif
  188. #endif   /*  CURSES  */
  189. #endif   /* _WINDOWS */
  190. #define BOOLEAN_DEFINED
  191. #endif
  192.  
  193. #ifndef BOOL
  194. #define BOOL BOOLEAN
  195. #endif
  196. #ifndef YES
  197. #define YES (BOOLEAN)1
  198. #define NO (BOOLEAN)0
  199. #endif
  200.  
  201. #define TCP_PORT 80     /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
  202. #define OLD_TCP_PORT 2784       /* Try the old one if no answer on 80 */
  203. #define DNP_OBJ 80      /* This one doesn't look busy, but we must check */
  204.                         /* That one was for decnet */
  205.  
  206. /*      Inline Function WHITE: Is character c white space? */
  207. /*      For speed, include all control characters */
  208.  
  209. #define WHITE(c) (((unsigned char)(TOASCII(c))) <= 32)
  210.  
  211.  
  212. /*
  213.  
  214. Sucess (>=0) and failure (<0) codes
  215.  
  216.  */
  217.  
  218. #define HT_REDIRECTING 29996
  219. #define HT_LOADED 29997                 /* Instead of a socket */
  220. #define HT_INTERRUPTED -29998
  221. #define HT_NOT_LOADED -29999
  222. #define HT_OK           0               /* Generic success*/
  223.  
  224. #define HT_NO_ACCESS    -10             /* Access not available */
  225. #define HT_FORBIDDEN    -11             /* Access forbidden */
  226. #define HT_INTERNAL     -12             /* Weird -- should never happen. */
  227. #define HT_BAD_EOF      -12             /* Premature EOF */
  228.  
  229.  
  230. #include "HTString.h"   /* String utilities */
  231.  
  232. #ifndef va_arg
  233. #ifdef __STDC__
  234. #include <stdarg.h>
  235. #else
  236. #include <varargs.h>
  237. #endif
  238. #endif
  239.  
  240. /*
  241.  
  242. Out Of Memory checking for malloc() return:
  243.  
  244.  */
  245. #ifndef __FILE__
  246. #define __FILE__ ""
  247. #define __LINE__ ""
  248. #endif
  249.  
  250. #include "LYexit.h"
  251.  
  252. #define outofmem(file, func) \
  253.  { fprintf(stderr, "%s %s: out of memory.\nProgram aborted.\n", file, func); \
  254.   exit(1);}
  255. /* extern void outofmem PARAMS((const char *fname, const char *func)); */
  256.  
  257.  
  258. /*
  259.  
  260.   WHO PUT THESE IN AND WHAT ARE THEY ANYWAY?
  261.   
  262.  */
  263. #ifdef THEY_WILL_BE_REMOVED
  264. extern void msg_init PARAMS((int height));
  265. extern void msg_printf PARAMS((int y, const char *fmt, ...));
  266. extern void msg_exit PARAMS((int wait_for_key));
  267. #endif
  268.  
  269. /*
  270.  
  271. Upper- and Lowercase macros
  272.  
  273.    The problem here is that toupper(x) is not defined officially unless isupper(x) is.
  274.    These macros are CERTAINLY needed on #if defined(pyr) || define(mips) or BDSI
  275.    platforms. For safefy, we make them mandatory.
  276.    
  277.  */
  278. #include <ctype.h>
  279. #include <string.h>
  280.  
  281. #ifndef TOLOWER
  282.   /* Pyramid and Mips can't uppercase non-alpha */
  283. #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : (c))
  284. #define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : (c))
  285. #endif /* ndef TOLOWER */
  286.  
  287. /*
  288.  
  289. The local equivalents of CR and LF
  290.  
  291.    We can check for these after net ascii text has been converted to the local
  292.    representation. Similarly, we include them in strings to be sent as net ascii after
  293.    translation.
  294.    
  295.  */
  296. #define LF   FROMASCII('\012')  /* ASCII line feed LOCAL EQUIVALENT */
  297. #define CR   FROMASCII('\015')  /* Will be converted to ^M for transmission */
  298.  
  299. #endif /* HTUTILS_H */
  300.  
  301. /*
  302.  
  303.    end of utilities */
  304.